import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:universal_io/io.dart';

import '../../config.dart';

enum StatusBarType {
  white,
  black,
}

const Color defaultColor = Color(0xFF007AFF);
const Color defaultSecondaryColor = Color(0xFFF99B7D);
const Color defaultBgColor = Color(0xFFF2F1F6);
const Color defaultAppBarBgColor = Color(0xFFF2F1F6);
const Color defaultAppBarTextColor = Colors.black;
const Color defaultTextColor = Colors.black;
const Color defaultTextSubColor = Color(0xff8f8f8f);
const Color defaultLineColor = Color(0xFFb2b1af);
const Color defaultToastTextColor = Color(0xFFFFFFFF);
const Color defaultToastBgColor = Color(0xBB000000);
const Color defaultWarningColor = Color(0XFFEA4F3D);

StatusBarType JmStatusBarStyle = StatusBarType.white;

SystemUiOverlayStyle JmStatusBar({StatusBarType? type, Color? navColor}) {
  StatusBarType statusBarType = type ?? JmStatusBarStyle;

  if (Platform.isAndroid) {
    return SystemUiOverlayStyle(
        statusBarColor: Colors.transparent,
        //有Appbar时，会被覆盖
        statusBarIconBrightness: statusBarType == StatusBarType.white
            ? Brightness.light
            : Brightness.dark,
        //底部navigationBar背景颜色
        systemNavigationBarColor: navColor ?? JmColors.bg);
  }

  return statusBarType == StatusBarType.white
      ? SystemUiOverlayStyle.light
      : SystemUiOverlayStyle.dark;
}

SystemUiOverlayStyle JmStatusBarLight() {
  if (Platform.isAndroid) {
    return const SystemUiOverlayStyle(
        statusBarColor: Colors.transparent,
        //有Appbar时，会被覆盖
        statusBarIconBrightness: Brightness.light,
        //底部navigationBar背景颜色
        systemNavigationBarColor: Colors.white);
  }

  return SystemUiOverlayStyle.light;
}

JmColorsData JmColors = JmColorsData();

class JmColorsData {
  Color main;
  Color secondary;
  Color bg;
  Color appBarBg;

  //Color line;
  //Color warning;

  //Color toastText;
  Color toastBg;
  //Color titleTextColor;

  Color get primary => main;
  Color get textColor => JmConfig.defTextStyle.color ?? defaultTextColor;
  Color get textSubColor => JmConfig.sbuTextStyle.color ?? defaultTextSubColor;

  Color get appBarText =>
      JmConfig.appBarTextStyle.color ?? defaultAppBarTextColor;
  Color get toastText => JmConfig.toastTextStyle.color ?? defaultToastTextColor;
  Color div;

  Color get line => div;

  JmColorsData({
    this.main = defaultColor,
    this.secondary = defaultSecondaryColor,
    this.bg = defaultBgColor,
    this.appBarBg = defaultAppBarBgColor,
    //this.appBarText = defaultAppBarTextColor,
    //this.line = defaultLineColor,
    //this.warning = Colors.redAccent,
    //this.toastText = defaultToastTextColor,
    this.toastBg = defaultToastBgColor,
    //this.titleTextColor = const Color(0xFFEEFBFF),
    // this.textColor = defaultTextColor,
    //this.textSubColor = defaultTextSubColor,
    this.div = defaultLineColor,
  });
}
//
// class JmColorsData {
//   static Color main = const Color(0xFF3498DB);
//   static Color secondary = const Color(0xFF3B9188);
//   static Color bg = const Color(0xFFEEFBFF);
//   static Color appBarBg = const Color(0xFFEEFBFF);
//   static Color appBarText = const Color(0xFF3B4856);
//
//   static const Color line = Color(0xFFEEEEEE);
//   static const Color warning = Colors.redAccent;
//
//   //static const Color title_bg = Color(0xFFFFFFFF);
//
//   static Color toastText = const Color(0xffcf564f);
//   static Color toastBg = const Color(0xb2ffffff);
//
//   static Color titleTextColor = const Color(0xFFEEFBFF);
//   static Color textColor = const Color(0xFF3B4856);
//   static Color textSubColor = const Color(0xFF3B4856).withAlpha(180);
// }
